<script src="https://cdn.bootcss.com/reconnecting-websocket/1.0.0/reconnecting-websocket.min.js"></script>
</script>
<script src="https://cdn.bootcss.com/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
<script type="text/javascript">
var host = "${ws_host!''}"
if (host != "") {
    const h = vue.$createElement;
    var ws = new ReconnectingWebSocket(host);
    ws.onopen = function() {
        var json = {
            code: 101,
            token: $.cookie('token')
        }
        ws.send(JSON.stringify(json))
        // console.log('connectd') 
    }
    ws.onclose = function() {}
    ws.onerror = function() {};
    ws.onmessage = function(data) {
        // console.log(data.data)
        var json = jQuery.parseJSON(data.data);
        if (json.code == '102') {
            var noti = vue.$notify({
                title: json.title,
                message: h('i', { style: 'color: teal' }, json.content),
                onClick: function() {
                    noti.close()
                }
            });
        }
    }
}
</script>